
#include "stdafx.h"
#include "CChannel.h"
#include "CAblationParameterEx.h"
#include "CEPTDeviceData.h"

CEPTDeviceData::CEPTDeviceData()
{
	m_pAblationData = new BYTE[12];
	m_pStatusResponse = new BYTE[6];
	m_bResetPacket = FALSE;

	SecureZeroMemory(m_pAblationData,12);
	SecureZeroMemory(m_pStatusResponse,6);

	cout<<"Memory has been initialized and reset!";
}


CEPTDeviceData::~CEPTDeviceData()
{
	if(NULL != m_pAblationData)
	{
		delete[] m_pAblationData;
		m_pAblationData = NULL;
	}

	if(NULL != m_pStatusResponse)
	{
		delete[] m_pStatusResponse;
		m_pStatusResponse = NULL;
	}

	cout<<"Memory allocated to m_pAblationData and m_pStatusResponse has been released.";
}

INT32 CEPTDeviceData::GetParameterAt(INT32 f_lowIdx, INT32 f_highIdx)
{
	INT32 l_iAblationParameter = 0;

	l_iAblationParameter = m_pAblationData[f_highIdx];
	l_iAblationParameter = l_iAblationParameter<<8;
	l_iAblationParameter += m_pAblationData[f_lowIdx];

	return l_iAblationParameter;
}

INT32 CEPTDeviceData::GetDeviceMode()
{
	INT32 l_iDeviceMode = 9;
	l_iDeviceMode += m_pStatusResponse[0];

	return l_iDeviceMode;
}

VOID CEPTDeviceData::ResetBuffer()
{
	if(NULL != m_pAblationData)
	{
		SecureZeroMemory(m_pAblationData,12);
	}

	if(NULL != m_pStatusResponse)
	{
		SecureZeroMemory(m_pStatusResponse,6);
	}
}


VOID CEPTDeviceData::GetAblationParameter(CAblationParameterEx & f_objCAblParamEx)
{
	INT32 l_iTemp = GetParameterAt(PARAM_TEMP_LOW,PARAM_TEMP_HIGH);
	INT32 l_iDura = GetParameterAt(PARAM_DURA_LOW,PARAM_DURA_HIGH);
	INT32 l_iCurr = GetParameterAt(PARAM_CURR_LOW,PARAM_CURR_HIGH);
	INT32 l_iVolt = GetParameterAt(PARAM_VOLT_LOW,PARAM_VOLT_HIGH);
	INT32 l_iImp = GetParameterAt(PARAM_IMP_LOW,PARAM_IMP_HIGH);
	INT32 l_iPower = GetParameterAt(PARAM_POW_LOW,PARAM_POW_HIGH);


}
